package soul.service;

import soul.entity.User;
import soul.mapper.UserDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by sunzhengjie on 2016/11/22.
 */
@Service
public class UserService {

    private static Logger LOGGER = LoggerFactory.getLogger(UserService.class);

    @Autowired
    private UserDao userDao;

    public User checkUserCredential(User user) {
        if (user != null) {
            if (!StringUtils.isEmpty(user.getName())) {
                if (!StringUtils.isEmpty(user.getPassword())) {
                    Map<String,Object> param = new HashMap<>();
                    param.put("name",user.getName());
                    param.put("password",user.getPassword());
                    User userGot = userDao.getUser(param);
                    return userGot;
                }
            }
        }
        return null;
    }
}
